var Test = {
	obj : null,
	div : null,
	arr : [//这一部分自己扩展
		
		['北京市'],  
		['上海市'],  
		['天津市'],  
		['重庆市'],  
		['|'],
		['安徽省','合肥','芜湖','蚌埠','淮南','马鞍山','淮北','铜陵','安庆','黄山','滁州','阜阳','宿州','巢湖','六安','亳州','池州','宣城'], 
		['福建省','福州','厦门','莆田','三明','泉州','漳州','南平','龙岩','宁德'], 
		['甘肃省',"兰州","嘉峪关","金昌","白银","天水","武威","张掖","平凉","酒泉","庆阳","定西","陇南","临夏","甘南"], 
		['广东省','广州','深圳','珠海','汕头','韶关','佛山','江门','湛江','茂名','肇庆','惠州','梅州','汕尾','河源','阳江','清远','东莞','中山','潮州','揭阳','云浮'], 
		['广西自治区','南宁','柳州','桂林','梧州','北海','防城港','钦州','贵港','玉林','百色','贺州','河池','来宾','崇左'], 
		['贵州省','贵阳',"六盘水","遵义","安顺","铜仁","毕节","黔西南","黔东南","黔南"], 
		['海南省','海口','三亚'], 
		['河北省','石家庄','唐山','秦皇岛','邯郸','邢台','保定','张家口','承德','沧州','廊坊','衡水'], 
		['河南省','郑州','开封','洛阳','平顶山','焦作','鹤壁','新乡','安阳','濮阳','许昌','漯河','三门峡','南阳','商丘','信阳','周口','驻马店'], 
		['黑龙江','哈尔滨','齐齐哈尔','鸡西','鹤岗','双鸭山','大庆','伊春','佳木斯','七台河','牡丹江','黑河','绥化','大兴安岭'], 
		['湖北省','武汉','黄石','襄樊','十堰','荆州','宜昌','荆门','鄂州','孝感','咸宁','随州','恩施'], 
		['湖南省','长沙','株洲','湘潭','衡阳','邵阳','岳阳','常德','张家界','益阳','郴州','永州','怀化','娄底','湘西'], 
		['吉林省','长春','吉林','四平','辽源','通化','白山','松原','白城','延边'], 
		['江苏省','南京','无锡','徐州','常州','苏州','南通','连云港','淮安','盐城','扬州','镇江','泰州','宿迁'], 
		['江西省','南昌','景德镇','萍乡','九江','新余','鹰潭','赣州','吉安','宜春','抚州','上饶'], 
		['辽宁省','沈阳','大连','鞍山','抚顺','本溪','丹东','锦州','营口','阜新','辽阳','盘锦','铁岭','朝阳','葫芦岛'], 
		['内蒙古自治区','呼和浩特','包头','乌海','赤峰','通辽','鄂尔多斯','呼伦贝尔','巴彦淖尔','乌兰察布','兴安','锡林郭勒','阿拉善'], 
		['宁夏自治区','银川',"石嘴山","吴忠","固原","中卫"], 
		['青海省',"西宁","海东","海北","黄南","海南","果洛","玉树","海西"], 
		['山东省','济南','青岛','淄博','枣庄','东营','烟台','潍坊','威海','济宁','泰安','日照','莱芜','临沂','德州','聊城','滨州','菏泽'], 
		['山西省','太原','大同','阳泉','长治','晋城','朔州','晋中','运城','忻州','临汾','吕梁'], 
		['陕西省','西安','铜川','宝鸡','咸阳','渭南','延安','汉中','榆林','安康','商洛'], 
		['四川省','成都','自贡','攀枝花','泸州','德阳','绵阳','广元','遂宁','内江','乐山','南充','宜宾','广安','达州','眉山','雅安','巴中','资阳',"阿坝","甘孜","凉山"], 
		['西藏自治区',"拉萨","昌都","山南","日喀则","那曲","阿里","林芝"], 
		['新疆自治区','乌鲁木齐',"克拉玛依","吐鲁番","哈密","和田","阿克苏","喀什","克孜勒苏柯尔克孜","巴音郭楞蒙古","昌吉","博尔塔拉蒙古","伊犁哈萨克","塔城","阿勒泰"], 
		['云南省','昆明','曲靖','玉溪',"保山","昭通","丽江","普洱","临沧","文山","红河","西双版纳","楚雄","大理","德宏","怒江","迪庆"], 
		['浙江省','杭州','宁波','温州','嘉兴','湖州','绍兴','金华','衢州','舟山','台州','丽水'], 
		['|'],
		['香港特别行政区'],  
		['澳门特别行政区'],  
		['台湾省',"台北","高雄","基隆","台中","台南","新竹","嘉义"] 

	],
	Show : function(o){
		this.obj = o;
		this.Close();
		var d = document.createElement('div');
		d.id = "city_picker_div";
		this.div = d;
		with(d.style){
			width = '350px';
			height = 'auto';
			border = '1px solid #cccccc';
			background = '#F5F5F5';
			opacity = 1;
			position = 'absolute';
			left = o.offsetLeft + 'px';
			top = o.offsetTop + o.offsetHeight + 'px';
			padding = '0 10px 10px 10px';
			fontSize = '12px';
			lineHeight = '24px';
		}
		
		var g = document.createElement('div');
		g.className = 'clearfix';
		g.innerHTML = '<a href="javascript:Test.Close();" style="float:right">关闭</a>';
		d.appendChild(g);
		
		var e = document.createElement('div');
		for(var i = 0; i < this.arr.length; i ++){
			if(this.arr[i][0]!='|'){
				e.innerHTML += '<a href="javascript:Test.ShowCity(' + i + ');void(0);">' + this.arr[i][0] + '</a> ';
			} else {
				e.innerHTML += this.arr[i][0] + ' ';
			}
		}
		d.appendChild(e);
		
		var f = document.createElement('div');
		d.appendChild(f);
		
		document.getElementById("edit-profile-main-field-user-city").appendChild(d);
	},
	ShowCity : function(i){
		if(this.arr[i].length == 1) return Test.SetCity(this.arr[i][0]);
		this.div.childNodes[2].innerHTML = '';
		for(var k = 1; k < this.arr[i].length; k ++){
			this.div.childNodes[2].innerHTML += '<a href="javascript:Test.SetCity(\'' + this.arr[i][k] + '\');void(0);">' + this.arr[i][k] + '</a> ';
		}
	},
	SetCity : function(s){
		this.obj.value = s;
		this.Close();
	},
	Close : function(){
		if(this.div){
			this.div.parentNode.removeChild(this.div);
			this.div = null;
		}
	}
};

(function ($) {

	$(document).ready(function(){	
		$("#edit-profile-main-field-user-city-und-0-value").click(function(){
			Test.Show(this);
		});
	});
	
	
	//Override drupal core behavior
	Drupal.behaviors.password = {
	  attach: function (context, settings) {
	    var translate = settings.password;
	    $('input.password-field', context).once('password', function () {
	      var passwordInput = $(this);
	      var innerWrapper = $(this).parent();
	      var outerWrapper = $(this).parent().parent();
	
	      // Add identifying class to password element parent.
	      innerWrapper.addClass('password-parent');
	
	      // Add the password confirmation layer.
	      $('input.password-confirm', outerWrapper).parent().prepend('<div class="password-confirm"><span><i></i></span></div>').addClass('confirm-parent');
	      var confirmInput = $('input.password-confirm', outerWrapper);
	      var confirmResult = $('div.password-confirm', outerWrapper);
	      var confirmChild = $('span', confirmResult);
	
	      // Add the password meter.
	      var passwordMeter = '<div class="password-strength"><div class="password-strength-text" aria-live="assertive"></div><div class="password-strength-title">' + translate['strengthTitle'] + '</div><div class="password-indicator"><div class="indicator"></div></div></div>';
	      $(innerWrapper).prepend(passwordMeter);
	
	      // Check the password strength.
	      var passwordCheck = function () {
	
	        // Evaluate the password strength.
	        var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password);
	
	        // Adjust the length of the strength indicator.
	        $(innerWrapper).find('.indicator').css('width', result.strength + '%');
	
	        // Update the strength indication text.
	        $(innerWrapper).find('.password-strength-text').html(result.indicatorText);
	
	        passwordCheckMatch();
	      };
	
	      // Check that password and confirmation inputs match.
	      var passwordCheckMatch = function () {
	
	        if (confirmInput.val()) {
	          var success = passwordInput.val() === confirmInput.val();
	
	          // Show the confirm result.
	          confirmResult.css({ visibility: 'visible' });
	
	          // Remove the previous styling if any exists.
	          if (this.confirmClass) {
	            confirmChild.removeClass(this.confirmClass);
	          }
	
	          // Fill in the success message and set the class accordingly.
	          var confirmClass = success ? 'ok' : 'error';
	          confirmChild.addClass(confirmClass);
	          this.confirmClass = confirmClass;
	        }
	        else {
	          confirmResult.css({ visibility: 'hidden' });
	        }
	      };
	
	      // Monitor keyup and blur events.
	      // Blur must be used because a mouse paste does not trigger keyup.
	      passwordInput.keyup(passwordCheck).focus(passwordCheck).blur(passwordCheck);
	      confirmInput.keyup(passwordCheckMatch).blur(passwordCheckMatch);
	    });
	  }
	};
	
	
})(jQuery); 


